<template>
  <div>
    <el-form :inline="false" size="normal">
      <el-form-item label="" style="margin:0 auto" class="textarea">
        <el-input
          type="textarea"
          v-model="ch_Content"
          placeholder="输入中英文翻译"
          @input="fanyiChange"
        ></el-input
        ><el-input
          type="textarea"
          v-model="fanyiStr"
          placeholder="结果..."
        ></el-input>
      </el-form-item>
      <el-form-item label="" size="normal">
        <el-button type="primary" size="default">翻译</el-button>
        <el-button type="info" @click="clear_textarea">清空</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "Fanyi",

  data() {
    return {
      ch_Content: "",
      fanyiStr: ""
    };
  },

  mounted() {},

  methods: {
    fanyiChange(val) {
      this.axios
        .get(`https://api.66mz8.com/api/translation.php?info=${val}`)
        .then(res => {
          this.fanyiStr = res.data.fanyi;
        })
        .catch(err => {
          console.error(err);
        });
    },
    clear_textarea() {
      this.fanyiStr = "";
      this.ch_Content = "";
    }
  }
};
</script>

<style lang="scss">
.el-textarea__inner {
  height: 200px;
  margin: 10px 0;
  font-size: 24px !important;
  border: 1px solid #006cbe !important;
  border-radius: 10px !important;
}
</style>
